package dame;

import java.util.Arrays;

public class Test2 {
    public static void mySort(int[] array){
        for (int i=1;i< array.length;i++){
            int tmp = array[i];
            int j = i-1;
            for (;j>=0;j--){
                if (array[j]>tmp){
                    array[j+1] = array[j];
                }else {
                    array[j+1] = tmp;
                    break;
                }
            }
            array[j+1] = tmp;
        }
    }

    public static void main(String[] args) {
        int[] array = new int[]{10,2,6,4,3,7,8};
        System.out.println("排序前:"+ Arrays.toString(array));
        mySort(array);
        System.out.println("排序后:"+ Arrays.toString(array));
    }
}
